﻿<Window x:Class="Brjnk.GpxExplorer.UI.SettingsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:common="clr-namespace:Brjnk.Common;assembly=Common"
        xmlns:l="clr-namespace:Brjnk.GpxExplorer.Localization"
        xmlns:maps="clr-namespace:Brjnk.Maps;assembly=Maps"
        xmlns:my="clr-namespace:Brjnk.GpxExplorer.UI.Controls"
        xmlns:workspace="clr-namespace:Brjnk.GpxExplorer.Workspace"
        Title="{l:Loc titleSettings}"
        Width="500"
        MinWidth="300"
        MinHeight="300"
        Loaded="Window_Loaded">
    <!--  DataContext celého okna je nastaven na Application.Settings (typ Settings)  -->
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"
                              MinWidth="100"
                              MaxWidth="200" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <ListBox>
            <ListBoxItem Name="general"
                         Content="{l:Loc settingsGeneral}"
                         IsSelected="True" />
            <ListBoxItem Name="units" Content="{l:Loc settingsUnits}" />
            <ListBoxItem Name="clipboard" Content="{l:Loc settingsClipboard}" />
            <ListBoxItem Name="language" Content="{l:Loc settingsLanguage}" />
        </ListBox>

        <!--  Obecné  -->
        <StackPanel Grid.Column="1" Visibility="{Binding ElementName=general, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
            <TextBlock Text="{l:Loc generalInternetMode}" />
            <my:EnumPicker x:Name="networkModePicker"
                           EnumType="{x:Type maps:NetworkMode}"
                           Value="{Binding NetworkMode}" />
            <TextBlock TextWrapping="Wrap">
                <TextBlock.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=networkModePicker, Path=Value}" Value="Online">
                                <Setter Property="TextBlock.Text" Value="{l:Loc generalOnlineInfo}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ElementName=networkModePicker, Path=Value}" Value="Offline">
                                <Setter Property="TextBlock.Text" Value="{l:Loc generalOfflineInfo}" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ElementName=networkModePicker, Path=Value}" Value="DataSaving">
                                <Setter Property="TextBlock.Text" Value="{l:Loc generalDataSavingInfo}" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
            <CheckBox Content="{l:Loc generalAllowMoreThanOnePushpin}" IsChecked="{Binding AllowMoreThanOnePushpin}" />
            <CheckBox Content="{l:Loc generalRoutePointsMultipleSelection}" IsChecked="{Binding RoutePointsMultipleSelectionMode}" />
            <CheckBox Content="{l:Loc generalTrackPointsMultipleSelection}" IsChecked="{Binding TrackPointsMultipleSelectionMode}" />
            <CheckBox Content="{l:Loc generalZoomViaDoubleClick}" IsChecked="{Binding EnableDoubleClick}" />
            <CheckBox Name="chbxVersionCheck"
                      Content="{l:Loc generalAutoCheckForNewVersion,
                                      Binding={Binding Source={workspace:GetWorkspace},
                                                       Path=VersionInfo.NewVersionCheckPeriod}}"
                      IsChecked="{Binding AutoCheckForNewVersion}" />
            <CheckBox Margin="20 0 0 0"
                      Content="{l:Loc generalAskBeforeCheckForNewVersion}"
                      IsEnabled="{Binding ElementName=chbxVersionCheck,
                                          Path=IsChecked}"
                      IsChecked="{Binding AskBeforeCheckForNewVersion}" />
            <TextBlock Text="{l:Loc generalTracksAndRoutesEditing}" FontWeight="Bold" />
            <CheckBox Content="{l:Loc generalSelectPathPointsDuringEditing}" IsChecked="{Binding SelectPathPointsDuringEditing}" />
            <CheckBox Content="{l:Loc generalRequireCtrlPressedDuringEditing}" IsChecked="{Binding RequireCtrlButtonDuringEditing}" />
        </StackPanel>

        <!--  Jednotky  -->
        <Grid Grid.Column="1" Visibility="{Binding ElementName=units, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0" Text="{l:Loc unitsDistance}" />
            <my:EnumPicker Grid.Row="0"
                           Grid.Column="1"
                           EnumType="{x:Type common:DistanceUnit}"
                           Value="{Binding Source={x:Static common:UnitsSettings.Instance},
                                           Path=Distance}" />
            
            <TextBlock Grid.Row="1" Text="{l:Loc unitsElevation}" />
            <my:EnumPicker Grid.Row="1"
                           Grid.Column="1"
                           EnumType="{x:Type common:DistanceUnit}"
                           Value="{Binding Source={x:Static common:UnitsSettings.Instance},
                                           Path=Elevation}" />

            <TextBlock Grid.Row="2" Text="{l:Loc unitsSpeed}" />
            <my:EnumPicker Grid.Row="2"
                           Grid.Column="1"
                           EnumType="{x:Type common:SpeedUnit}"
                           Value="{Binding Source={x:Static common:UnitsSettings.Instance},
                                           Path=Speed}" />

            <TextBlock Grid.Row="3" Text="{l:Loc unitsAcceleration}" />
            <my:EnumPicker Grid.Row="3"
                           Grid.Column="1"
                           EnumType="{x:Type common:AccelerationUnit}"
                           Value="{Binding Source={x:Static common:UnitsSettings.Instance},
                                           Path=Acceleration}" />

            <TextBlock Grid.Row="4" Text="{l:Loc unitsCoordinates}" />
            <my:EnumPicker Grid.Row="4"
                           Grid.Column="1"
                           EnumType="{x:Type common:CoordinationFormat}"
                           Value="{Binding Source={x:Static common:UnitsSettings.Instance},
                                           Path=Gps}" />

            <TextBlock Grid.Row="5" Text="{l:Loc unitsCentimetersOrInches}" />
            <my:EnumPicker Grid.Row="5"
                           Grid.Column="1"
                           EnumType="{x:Type common:CmOrIn}"
                           Value="{Binding Source={x:Static common:UnitsSettings.Instance},
                                           Path=CentimeterOrInch}" />

            <TextBlock Grid.Row="6"
                       Grid.ColumnSpan="2"
                       FontWeight="Bold"
                       Foreground="Red"
                       Text="{l:Loc unitsInfo}" />
        </Grid>

        <!--  Schránka  -->
        <StackPanel Grid.Column="1" Visibility="{Binding ElementName=clipboard, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
            <TextBlock Style="{StaticResource HeaderStyle}" Text="{l:Loc clipboardCoordinates}" />
            <CheckBox Content="{l:Loc clipboardCoordinatesCreateWaypoint}" IsChecked="{Binding ClipboardSettings.CoordinatesCreateWaypoint}" />
            <Grid>
                <CheckBox Content="{l:Loc clipboardCoordinatesSearch}" IsChecked="{Binding ClipboardSettings.CoordinatesSearch}" />
                <my:ColorPicker Width="100"
                                HorizontalAlignment="Right"
                                Color="{Binding ClipboardSettings.CoordinatesSearchColor}" />
            </Grid>
            <CheckBox Content="{l:Loc clipboardCoordinatesAsk}" IsChecked="{Binding ClipboardSettings.CoordinatesAsk}" />
            <TextBlock Style="{StaticResource HeaderStyle}" Text="{l:Loc clipboardDateTime}" />
            <Grid>
                <CheckBox Content="{l:Loc clipboardDateTimeSearch}" IsChecked="{Binding ClipboardSettings.DateTimeSearch}" />
                <my:ColorPicker Width="100"
                                HorizontalAlignment="Right"
                                Color="{Binding ClipboardSettings.DateTimeSearchColor}" />
            </Grid>
            <CheckBox Content="{l:Loc clipboardDateTimeAsk}" IsChecked="{Binding ClipboardSettings.DateTimeAsk}" />
        </StackPanel>
        <!--  Jazyk  -->
        <StackPanel Grid.Column="1"
                    Orientation="Vertical"
                    Visibility="{Binding ElementName=language,
                                         Path=IsSelected,
                                         Converter={StaticResource BooleanToVisibilityConverter}}">
            <TextBlock Text="{l:Loc language}" />
            <ComboBox HorizontalAlignment="Left"
                      ItemsSource="{Binding Source={workspace:GetWorkspace},
                                            Path=Languages}"
                      SelectedItem="{Binding Language}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding NativeName}" />
                            <TextBlock Text=" | " />
                            <TextBlock Text="{Binding FullName}" />
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
        </StackPanel>
    </Grid>
</Window>